#include <iostream>
#include <fcntl.h>
#include <sys/stat.h>
#include <dirent.h>
#include <string>

using std::cout;
using std::endl;

std::string getMask(struct dirent *dt, std::string path)
{
    std::string ret;
    struct stat st{};
    stat(path.c_str(), &st);

    if (dt->d_type == DT_REG)
    {
        ret += "-";
    }
    else if (dt->d_type == DT_DIR)
    {
        ret += "d";
    }

    return ret;
}

void test()
{
    DIR *dir;
    struct dirent *dt;
    dir = opendir(".");
    while ((dt = readdir(dir)))
    {
        cout << getMask(dt, "./" + std::string(dt->d_name)) << ", " << dt->d_name << endl;
    }
}

int main(int args, char *argv[])
{
    test();
    return 0;
}